﻿@model HZU.ZP.Domain.Model.CompanyInformationView
@{
    Layout = "_CompanyLayout";
}
<style type="text/css">
    .imgDiv {
        display: inline-block;
        position: relative;
        float: left;
        margin-right: 20px;
        margin-bottom: 20px;
    }

    img {
        width: 300px;
        height: 200px;
        margin-right: 10px;
        margin-bottom: 10px;
    }

    .delete {
        position: absolute;
        top: 0px;
        right: 0px;
        width: 10px;
        height: 10px;
        /*display: none; */
    }
</style>
<script>
    $(document).ready(function () {
        $("#UploadImg").on("change", "#file", function () {
            var file = $("#file").get(0);
            var files = file.files;
            var formdata = new FormData();
            for (var i = 0; i < files.length; i++) {
                formdata.append("files", files[i]);
            }

            $.ajax({
                type: 'Post',
                data: formdata,
                contentType: false,
                processData: false,
                url: "/CompanyInformation/UploadImg",
                success: function (result) {
                    if (result.returnCode == '999') {
                        alert('提交失败,重新尝试提交');
                        var file = document.getElementById('file');
                        file.value = '';
                        return false;
                    }
                    else if (result.returnCode == '4040') {
                        alert('文件不是.gif|.jpg|.jpeg|.png结尾');
                        var file = document.getElementById('file');
                        file.value = '';
                        return false;
                    }
                    else if (result.returnCode == '4050') {
                        alert('文件大于2M');
                         var file = document.getElementById('file');
                        file.value = '';
                        return false;
                    }else if (result.returnCode == '4060') {
                        alert('最多仅能上传4张图片！');
                         var file = document.getElementById('file');
                        file.value = '';
                        return false;
                    }else {
                        /**/
                        $("#UploadImg").append('<div class="imgDiv"><img src="' + result.picture + '"/><a href="#" class="delete" data-id="'+ result.id +'"><span class="glyphicon glyphicon-remove" style="color:red"></span></a></div>');
                        /**/
                        var file = document.getElementById('file');
                        file.value = '';
                    }
                }
            });
        });
        $("#saveCompanyInformation").click(function () {
            var infor = new Object();
            infor.Id = @Model.CompanyInformation.Id;
            infor.CompanyId = @Model.CompanyInformation.CompanyId;
            infor.CompanyName = $("#CompanyName").val();
            infor.Email = $("#Email").val();
            infor.Provincial = $("#Provincial").val();
            infor.Municipal = $("#Municipal").val();
            infor.Contacts = $("#Contacts").val();
            infor.Address = $("#Address").val();
            infor.PhoneNumber = $("#PhoneNumber").val();
            infor.CompanyType = $("#CompayType").val();
            infor.CompanySize = $("#CompaySize").val();
            infor.BigIndustry = $("#BigIndustry").val();
            infor.SmallIndustry = $("#SmallIndustry").val();
            infor.CompayIntroduction = $("#CompayIntroduction").val();
             $.ajax({
                type: "post",
                url: "/CompanyInformation/Save",
                contentType: "application/json",
                data: JSON.stringify(infor),
                dataType: "json",
                    success: function (message) {
                        if (message.returnCode == "001") {
                            alert("保存成功");
                            window.location.reload();
                        }
                        else{
                            alert("保存失败");
                        }
                }
            });
        });
        $(document).on('click','.delete',function () {
            if (confirm("确实要删除吗？")) {
                var del = false;
                var id = $(this).data("id");
                $.ajax({
                    type: 'post',
                    url: '/CompanyInformation/DeleteImg',
                    data: 'id=' + id,
                    async: false,
                    success: function (result) {
                        if (result.returnCode == '001') {
                            alert("删除图片成功！");
                            del = true;
                        }
                    }
                });
                if (del)
                    $(this).parent().remove();
                else
                    alert("删除图片失败！");
            }
            else {
        }
        });
    });
</script>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="row clearfix">
                <div class="col-md-2 column">

                </div>
                <div class="col-md-4 column">
                </div>
                <div class="col-md-2 column">
                    <h4><a href="/Position/GetComPosition?email=@User.Identity.Name&status=1" style="color:black;">职位管理</a></h4>
                </div>
                <div class="col-md-2 column">
                    <h4><a href="/ApplyRecord/GetApplyRecordCom?email=@User.Identity.Name" style="color:black;">应聘管理</a></h4>
                </div>
                <div class="col-md-2 column">
                    <h4 style="color:blue"><a href="/CompanyInformation/GetCompanyInformation?email=@User.Identity.Name">企业信息管理</a></h4>
                </div>
            </div>
        </div>
    </div>
    <br />
    <div class="row clearfix">
        <div class="col-md-6 column">
            <div class="form-group">
                <span style="margin-right:50px">公司名称</span><input type="text" style="width:50%" id="CompanyName" value="@(Model.CompanyInformation==null?"":Model.CompanyInformation.CompanyName)" disabled="disabled" />
            </div>
        </div>
        <div class="col-md-6 column">
            <div class="form-group">
                <span style="margin-right:50px">邮&thinsp; &thinsp;&thinsp; &thinsp;&thinsp;&thinsp;箱</span><input type="text" style="width:50%" id="Email" value="@(Model.CompanyInformation==null?"":Model.CompanyInformation.Email)" disabled="disabled" />
            </div>
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-md-6 column">
            <div class="form-group">
                <span style="margin-right:50px">省&thinsp; &thinsp;&thinsp; &thinsp;&thinsp;区</span>
                <select id="Provincial" style="width:25%">
                    <option value="@(Model.CompanyInformation==null?"广东":Model.CompanyInformation.Provincial)" style="display:none">@(Model.CompanyInformation == null ? "广东" : Model.CompanyInformation.Provincial)</option>
                </select>
                <select id="Municipal" style="width:25%">
                    <option value="@(Model.CompanyInformation==null?"惠州市":Model.CompanyInformation.Municipal)" style="display:none">@(Model.CompanyInformation == null ? "惠州市" : Model.CompanyInformation.Municipal)</option>
                </select>
            </div>
        </div>
        <div class="col-md-6 column">
            <div class="form-group">
                <span style="margin-right:50px">地&thinsp; &thinsp;&thinsp; &thinsp;&thinsp;&thinsp;址</span><input type="text" style="width:50%" id="Address" value="@(Model.CompanyInformation==null?"":Model.CompanyInformation.Address)" />
            </div>
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-md-6 column">
            <div class="form-group">
                <span style="margin-right:50px">联&thinsp;&thinsp;系&thinsp;&thinsp;人</span><input type="text" style="width:50%" id="Contacts" value="@(Model.CompanyInformation==null?"":Model.CompanyInformation.Contacts)" />
            </div>
        </div>
        <div class="col-md-6 column">
            <div class="form-group">
                <span style="margin-right:50px">手机号码</span><input type="text" style="width:50%" id="PhoneNumber" value="@(Model.CompanyInformation==null?"":Model.CompanyInformation.PhoneNumber)" />
            </div>
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-md-6 column">
            <div class="form-group">
                <span style="margin-right:50px">公司类型</span>
                <select id="CompayType" style="width:49%">
                    <option style="display:none">@(Model.CompanyInformation == null ? "请选择" : Model.CompanyInformation.CompanyType)</option>
                    <option>国企</option>
                    <option>外资(欧美)</option>
                    <option>外资(非欧美)</option>
                    <option>上市公司</option>
                    <option>合资</option>
                    <option>民营公司</option>
                    <option>政府机关</option>
                    <option>事业单位</option>
                    <option>非营利组织</option>
                    <option>创业公司</option>
                </select>
            </div>
        </div>
        <div class="col-md-6 column">
            <div class="form-group">
                <span style="margin-right:50px">公司规模</span>
                <select id="CompaySize" style="width:49%">
                    <option style="display:none">@(Model.CompanyInformation == null ? "请选择" : Model.CompanyInformation.CompanySize)</option>
                    <option>0-20人</option>
                    <option>20-99人</option>
                    <option>100-499人</option>
                    <option>500-999人</option>
                    <option>1000-9999人</option>
                    <option>10000人以上</option>
                </select>
            </div>
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-md-6 column">
            <div class="form-group">
                <span style="margin-right:50px">行业类别</span>
                <select id="BigIndustry" style="width:25%">
                    <option value="@(Model.CompanyInformation==null?"":Model.CompanyInformation.BigIndustry )" style="display:none">@(Model.CompanyInformation == null ? "" : Model.CompanyInformation.BigIndustry)</option>
                </select>
                <select id="SmallIndustry" style="width:25%">
                    <option value="@(Model.CompanyInformation==null?"":Model.CompanyInformation.SmallIndustry )" style="display:none">@(Model.CompanyInformation == null ? "" : Model.CompanyInformation.SmallIndustry)</option>
                </select>
            </div>
        </div>
        <div class="col-md-6 column">
            <div class="form-group">

            </div>
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="form-group">
                <span style="margin-right:50px;float:left">公司简介</span>
                <textarea id="CompayIntroduction" style="height:128px;width:90%" maxlength="1000" placeholder="请输入企业简介...">@(Model.CompanyInformation == null ? "" : Model.CompanyInformation.CompayIntroduction)</textarea>
            </div>
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="form-group" id="UploadImg">
                <span style="margin-right:50px;float:left">公司图片</span>
                <input type="file" id="file" value="选择需要上传的图片" style="float:left" accept=".jpg,.jpeg,.png" />
                <p style="color :red">支持.gif .jpg .jpeg .png文件，最多仅能上传4张图片！</p>
            </div>
            @foreach (var picture in Model.CompayPictures)
            {
                <div class="imgDiv">
                    <img src="@picture.Picture" />
                    <a href="#" class="delete" data-id="@picture.Id">
                        <span class="glyphicon glyphicon-remove" style="color:red"></span>
                    </a>
                </div>
            }
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div style="text-align:center">
                <button id="saveCompanyInformation" type="button" class="btn btn-default btn-info">保存</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="~/js/area.js"></script>
<script type="text/javascript" src="~/js/position.js"></script>
<script type="text/javascript" src="~/js/industry.js"></script>
<script type="text/javascript" src="~/js/select.js"></script>
